//
//  SeasonViewController.m
//  App-MyFairldy
//
//  Created by 客官大大 on 15/5/23.
//  Copyright (c) 2015年 客官大大. All rights reserved.
//

#import "SeasonViewController.h"

@interface SeasonViewController ()

@end

@implementation SeasonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITableView *seasonTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 200, 375, 427) style:UITableViewStylePlain];
    seasonTableView.delegate = self;
    seasonTableView.dataSource = self;
    seasonTableView.separatorColor = [UIColor clearColor];
    [self.view addSubview:seasonTableView];
    [seasonTableView release];
    
    UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 375, 260)];
    imageView1.backgroundColor = [UIColor clearColor];
    [self.view addSubview:imageView1];
    UIImage *image1 = [UIImage imageNamed:@"spring1.jpg"];
    UIImage *image2 = [UIImage imageNamed:@"summer1.jpg"];
    UIImage *image3 = [UIImage imageNamed:@"autumn1.jpg"];
    UIImage *image4 = [UIImage imageNamed:@"winter1.jpg"];
    NSMutableArray *array = [NSMutableArray array];
    [array addObject:image1];
    [array addObject:image2];
    [array addObject:image3];
    [array addObject:image4];
    imageView1.animationImages = array;
    imageView1.animationDuration = 5;
    imageView1.animationRepeatCount = 0;
    [imageView1 startAnimating];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *str = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:str];
    }
    if (indexPath.row == 0) {
        cell.textLabel.text = @"春季";
        cell.detailTextLabel.text = @"产于3-5月的食物";
        UIImage *spimage = [UIImage imageNamed:@"spring"];
        cell.imageView.image = spimage;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    } else if (indexPath.row == 1) {
        cell.textLabel.text = @"夏季";
        cell.detailTextLabel.text = @"产于6-8月的食物";
        UIImage *image1 = [UIImage imageNamed:@"summer"];
        cell.imageView.image = image1;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    } else if (indexPath.row == 2) {
        cell.textLabel.text = @"秋季";
        cell.detailTextLabel.text = @"产于9-11月的食物";
        UIImage *image2 = [UIImage imageNamed:@"autumn"];
        cell.imageView.image = image2;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    } else if (indexPath.row == 3) {
        cell.textLabel.text = @"冬季";
        cell.detailTextLabel.text = @"产于12-2月的食物";
        UIImage *image3 = [UIImage imageNamed:@"winter"];
        cell.imageView.image = image3;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 90;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        SeasonFirstViewController *seaonFirst = [[SeasonFirstViewController alloc] init];
        [self.navigationController pushViewController:seaonFirst animated:YES];
    } else if (indexPath.row == 1) {
        SeasonSecondViewController *seasonSecond = [[SeasonSecondViewController alloc] init];
        [self.navigationController pushViewController:seasonSecond animated:YES];
    } else if (indexPath.row == 2) {
        SeasonThirdViewController *seasonthird = [[SeasonThirdViewController alloc] init];
        [self.navigationController pushViewController:seasonthird animated:YES];
    } else if (indexPath.row == 3) {
        SeasonForthViewController *seasonForth = [[SeasonForthViewController alloc] init];
        [self.navigationController pushViewController:seasonForth animated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
